package com.ds.util;

import com.ds.client.exception.ProfileNotFoundException;
import com.ds.model.Enums;
import java.io.File;


/**
 *
 * @author exploredhiraj
 */
public class PomProfileComparator {

    public void compareProfiles(String inputPomFileName, String outputHtmlFileName, String profileNames)
            throws ProfileNotFoundException, Exception {
        String[] profilesToBeCompared = profileNames.split(",");
        File pomFile = new File(inputPomFileName);
        if (pomFile.exists()) {
            PomParser pomParser = new PomParser(pomFile);
            String outputFilePath = pomParser.generateOutput(Enums.OUTPUT_FORMAT.HTML, outputHtmlFileName, profilesToBeCompared);
            Runtime rt = Runtime.getRuntime();
            String[] commands = {"cmd", "/c", "start " + outputFilePath};
            rt.exec(commands);
            System.out.print("If you do not see the file read the result from: " + outputFilePath);
        } else {
            System.out.print("POM File not found!");
        }

    }

//    private static void traverseAllNodesAndPrintContents(Node node) {
//        System.out.print(node.getNodeName());
//        if (node.hasChildNodes()) {
//            for (int i = 0; i < node.getChildNodes().getLength(); i++) {
//                traverseAndPrintNode(node.getChildNodes().item(i));
//            }
//        } else {
//            System.out.println(node.getTextContent());
//        }
//    }

}